/* 模块化开发 */

import Vue from 'vue'
// 1.引入：类似于ocmmonJS的index.js，把所有路由集中到index.js后，再讲这个js文件导出到给main.js使用
import VueRouter from 'vue-router';

import Home from '../pages/Home.vue'
import User from '../pages/User.vue'
import Goods from '../pages/Goods.vue'
import Order from '../pages/Order.vue'
import NotFound from '../pages/NotFound.vue'

// 2.安装
Vue.use(VueRouter);

Vue.config.productionTip = false;

// 3.配置参数
const router = new VueRouter({
    routes: [
        /* 重定向 */
        {
            path: '/',
            redirect: '/home'
        },
        {
            path: '/home',
            component: Home
        },
        {
            path: '/user',
            component: User
        }, {
            path: '/goods',
            component: Goods
        }, {
            path: '/order',
            component: Order
        },
        /* 新增404 */
        {
            path:'/404',
            component:NotFound
        },
        /* 非设置的路由重定向到404 */
        {
            path:'*',
            redirect:'/404'
        }
    ]
})

export default router